<%-- 
    Document   : giatot_ganday
    Created on : Oct 10, 2011, 3:15:50 PM
    Author     : lethong
--%>
<%@page import="java.text.DecimalFormat"%>
<%@page import="java.util.ArrayList"%>
<%@page import="model.pojo.mathangPOJO"%>
<%int trang = 1;
    if (request.getAttribute("trang") != null) {
        trang = Integer.parseInt(String.valueOf(request.getAttribute("trang")));
    }

    int sotrang = 0;
    if (request.getAttribute("SoTrang") != null) {
        sotrang = Integer.parseInt(String.valueOf(request.getAttribute("SoTrang")));
    }
%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!-- Bắt đầu show sản phẩm-->
<div class="prodlist clearfix"> 
    <ul id="secondGallery" class="image-overlay">
        <%
            DecimalFormat myFormatter = new DecimalFormat("###,###");
            ArrayList<mathangPOJO> listMH = (ArrayList<mathangPOJO>) request.getAttribute("listMathang");
            for (int i = 0; i < listMH.size(); i++) {
                mathangPOJO mh = listMH.get(i);
                float tietkiem = (mh.getGiathuc() - mh.getGiakhuyenmai());
                float tyle = (tietkiem * 100) / mh.getGiathuc();
                String tenmh = mh.getTenmathang();
                String ten_sub = tenmh;

        %>
        <li>
            <span class="promotion"><span class="percent"><%=myFormatter.format(tyle)%>%</span></span>
            <a href="#">
                <%
                    if (tenmh.length() > 20) {
                        ten_sub = tenmh.substring(0, 20);%>
                    <span class="name"><%=ten_sub%>...</span>
                <%}else{%>
                    <span class="name"><%=ten_sub%></span>
                <%}%>
                <img src="<%=mh.getHinhanh()%>" />
                <div class="info">
                    <span class="priceM"><%=myFormatter.format(mh.getGiakhuyenmai())%> <sup>vnđ</sup></span><br />
                    <span class="info_i">Giá trị:</span><span class="price"><%=myFormatter.format(mh.getGiathuc())%> <sup>vnđ</sup></span><br />
                    <span class="info_i">Tiết kiệm:</span><span class="price"><%=myFormatter.format(tietkiem)%> <sup>vnđ</sup></span><br />
                    <%
                        String sdate = String.valueOf(mh.getNgaybatdau());
                        String syear = sdate.substring(0, 4);
                        String smonth = sdate.substring(5, 7);
                        String sday = sdate.substring(8);
                    %>
                    <span>Ngày <%=sday%> tháng <%=smonth%> năm <%=syear%></span>
                </div>
                <%
                if(mh.isTinhtrang()==1)
                                       {
                %>
                <div class="infoEnd_DB">Đã hết hạn</div>
                <%}else{%>
                <div class="infoEnd_DB">Cháy hàng</div>
                <%}%>
            </a>
        </li>
        <%}%>
    </ul>
</div>
        <%if (sotrang > 1) {%>
<div class="paging clearfix" >
    <%
        for (int i = 1; i <= sotrang; i++) {
            if (trang == i) {%>
    <a href='Giatot_ganday?Action=View&trang=<%=i%>' class='active'><%=i%></a>
    <%} else {%>
    <a href='Giatot_ganday?Action=View&trang=<%=i%>'><%=i%></a>
    <%}
        }%>
    <!--<a href="#"> 1 </a><span class='resultmsg'>Tìm thấy 5 kết quả!</span>-->
</div>
    <%}%>
<!-- Kết thúc-->
<script type="text/javascript">
       //$("#secondGallery").ImageOverlay({ border_color: "#FF8000", overlay_color: "#edd256", overlay_origin: "top", overlay_text_color: "#FFF", overlay_speed: 'medium', overlay_speed_out : 'medium' });
       $('#secondGallery a').hover(function(){
           $(this).parent().addClass('shadow_light lihover_prod');		
       },function(){
           $(this).parent().removeClass();
       });

</script>
